package org.rujue.modules.sys.utils;

import com.github.pagehelper.PageHelper;
import org.rujue.common.persistence.Page;
import org.rujue.common.utils.SpringContextHolder;
import org.rujue.modules.sys.dao.SysNoticeDao;
import org.rujue.modules.sys.entity.SysNotice;
import org.rujue.modules.sys.entity.User;
import org.rujue.modules.sys.service.UserService;

import java.util.List;

public class SysUtils {
    public static final String OFFICE_TYPE_COMPANY = "1";
    public static final String ROLE_ENNAME_COMMON_USER = "COMMON_USER";

    public static final String TABLE_NAME_SYS_NOTICE = "sys_notice";
    public static final String MENU_TYPE_MENU = "2";
    public static final String MENU_TYPE_PERMISSION = "3";



    private static final SysNoticeDao sysNoticeDao = SpringContextHolder.getBean(SysNoticeDao.class);
    private static final UserService userService = SpringContextHolder.getBean(UserService.class);
    public static List<SysNotice> getNoticeList(Integer pageSize){
        // 设置 pageSize 条数据，pageNum=1 表示第一页
        PageHelper.startPage(1, pageSize);
        PageHelper.orderBy("a.show_date DESC");
        // 查询语句必须紧跟 startPage 才能生效
        return sysNoticeDao.findList(new SysNotice());
    }

    public static List<User> getSaleUserList(){
        User user = new User();
        user.setSaleStop("0");
        return userService.findList(user);
    }
}
